package com.atguigu.gmall.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.product.feign.IndexFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * projectName: gmall
 *
 * @author: 陈鹏
 * time: 2022/10/5 19:35 星期三
 * description: 首页的控制层
 */
@Controller
@RequestMapping(value = "/page/index")
public class IndexController {

    @Autowired
    private IndexFeign indexFeign;

    /**
     * 打开首页
     * @param model
     * @return
     */
    @GetMapping
    public String index(Model model){
        //远程获取首页的分类信息
        List<JSONObject> categoryList = indexFeign.getIndexCategory();
        model.addAttribute("categoryList",categoryList);
        //打开首页
        return "index";
    }

}
